package com.hlz.flink.chapter05;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Hongliang Zhu
 * @create 2023-01-02 19:35
 */
public class SourceTest {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        List<Event> clicks = new ArrayList<>();
        clicks.add(new Event("Mary", "/home/", 1000L));
        clicks.add(new Event("Bob", "/home/", 2000L));
        clicks.add(new Event("Tom", "/cart/", 3000L));

        DataStreamSource<Event> dataStreamSource = env.fromCollection(clicks);

        dataStreamSource.print("1");


        DataStreamSource<String> streamSource2 = env.fromElements("111", "mary 100", "hello");
        streamSource2.print("2");

        env.execute();
    }
}
